package task;


import handingIn.HandingIn;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;


/**
 *
 * @author Hip Teen#
 */

@Entity
public class ExerciseSheet implements Serializable {
    
    
    private File exerciseSheetFile;
    
    private File solutionFile;
    
    private String exerciseSheetFileName;
    
    private String solutionFileName;
    
    @OneToOne(cascade= CascadeType.ALL)
    private TaskCategory category;
    
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dateOfRelease;
    
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dateOfReturn;
    
    private int correctionTime;
    
    private String name;
    
    //Liste von Aufgaben
    @OneToMany(cascade=CascadeType.ALL)
    private List<Task> exercises;
    
    //Liste von digitalen Abgaben
    @OneToMany(cascade=CascadeType.ALL)
    private List<HandingIn> handingIns;
    @Id
    @GeneratedValue
    private Long id;
    
    
    public ExerciseSheet() {
        this.exercises = new ArrayList<Task>();
        this.handingIns = new ArrayList<HandingIn>();
        this.exerciseSheetFileName ="";
        this.solutionFileName="";
        this.dateOfRelease= new Date();
        this.dateOfReturn = new Date();
    }

    public TaskCategory getCategory() {
        return category;
    }

    public void setCategory(TaskCategory category) {
        this.name = category.getName() + " " + (category.getCounter() + 1);
        this.category = category;
    }

    public Date getDateOfRelease() {
        return dateOfRelease;
    }

    public void setDateOfRelease(Date dateOfRelease) {
        this.dateOfRelease = dateOfRelease;
    }

    public Date getDateOfReturn() {
        return dateOfReturn;
    }

    public void setDateOfReturn(Date dateOfReturn) {
        this.dateOfReturn = dateOfReturn;
    }

    public List<Task> getExercises() {
        return exercises;
    }

    public void setExercises(List<Task> exercises) {
        System.out.println("Set Exercises aufgerufen");
        this.exercises = exercises;
    }

    public List<HandingIn> getHandingIns() {
        return handingIns;
    }

    public void setHandingIns(List<HandingIn> handingIns) {
        this.handingIns = handingIns;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getExerciseSheetFileName() {
        return exerciseSheetFileName;
    }

    public void setExerciseSheetFileName(String exerciseSheetFileName) {
        this.exerciseSheetFileName = exerciseSheetFileName;
    }

    public File getExerciseSheetFile() {
        return exerciseSheetFile;
    }

    public void setExerciseSheetFile(File exerciseSheetFile) {
        this.exerciseSheetFile = exerciseSheetFile;
    }

    public String getSolutionFileName() {
        return solutionFileName;
    }

    public void setSolutionFileName(String solutionFileName) {
        this.solutionFileName = solutionFileName;
    }

    public File getSolutionFile() {
        return solutionFile;
    }

    public void setSolutionFile(File solutionFile) {
        this.solutionFile = solutionFile;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public int getCorrectionTime() {
        return correctionTime;
    }

    public void setCorrectionTime(int correctionTime) {
        this.correctionTime = correctionTime;
    }
}
   